package com.ruoyi.web.xxj.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class UniqueOrderNumberGenerator {

    public static final SimpleDateFormat date_format = new SimpleDateFormat("yyyyMMddHHmmss");

    public static String generateOrderNumber(String prefix) {
        String timestamp = date_format.format(new Date());
        String randomNumber = generateRandomNumber();
        return prefix + timestamp + randomNumber;

    }

    private static String generateRandomNumber() {
        Random random = new Random();
        int randomNumber = random.nextInt(9999);
        return String.format("%04d", randomNumber);
    }
}
